package addToArrayForm;

import java.util.LinkedList;
import java.util.List;

public class Solution {
    public List<Integer> addToArrayForm(int[] num, int k) {
        LinkedList<Integer> list = new LinkedList<>();
        int index = num.length-1;
        while(index>=0||k!=0){
            int sum = k;
            if(index>=0){
                sum+=num[index];
                index--;
            }
            k = sum/10;
            list.addFirst(sum%10);
        }
        return list;
    }
}
